package cn.gson.crm.controller.student;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.gson.crm.controller.BaseServlet;
import cn.gson.crm.model.dao.GraduateDao;
import cn.gson.crm.model.entity.Graduate;

/**
 * 新增记录
 */
@WebServlet("/student/addrecord")
public class StudentAddrecordServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	private String id="";
	private GraduateDao graduateDao=new GraduateDao();

	protected void get(HttpServletRequest request, HttpServletResponse response) throws Exception {
		id=request.getParameter("id");
		Graduate graduate=graduateDao.getOneGraduate(id);
		request.setAttribute("graduate", graduate);
		forward("student/graduaterecordform.jsp");
	}

	protected void post(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String ways=request.getParameter("ways");
		String information=request.getParameter("information");
		boolean result=graduateDao.insertRecord(id, ways, information);
		if(!result){
			errorForward("新增失败", "student/graduaterecordform.jsp");
			return;
		}
		redirect("student/graduate");
	}

}
